* The toplevel is computed by walking up the GdkSurface
* hierarchy from context->client_surface until we find a
* window that is owned by some widget, and then calling
- * gtk_widget_get_toplevel() on that widget. This should
+ * gtk_widget_get_root() on that widget. This should
* handle both cases where we might have GdkSurfaces without widgets,
* and cases where GtkWidgets have strange window hierarchies
* (like a torn off GtkHandleBox.)
return !(priv->width_request == -1 && priv->height_request == -1);
}
-/**
- * gtk_widget_get_toplevel:
- * @widget: a #GtkWidget
- *
- * This function returns the topmost widget in the container hierarchy
- * @widget is a part of. If @widget has no parent widgets, it will be
- * returned as the topmost widget. No reference will be added to the
- * returned widget; it should not be unreferenced.
- *
- * Note the difference in behavior vs. gtk_widget_get_ancestor();
- * `gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)`
- * would return
- * %NULL if @widget wasn’t inside a toplevel window, and if the
- * window was inside a #GtkWindow-derived widget which was in turn
- * inside the toplevel #GtkWindow.
- *
- * To reliably find the toplevel #GtkWindow, use
- * gtk_widget_get_toplevel() and call GTK_IS_WINDOW()
- * on the result. For instance, to get the title of a widget's toplevel
- * window, one might use:
- * |[<!-- language="C" -->
- * static const char *
- * get_widget_toplevel_title (GtkWidget *widget)
- * {
- * GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- * if (GTK_IS_WINDOW (toplevel))
- * {
- * return gtk_window_get_title (GTK_WINDOW (toplevel));
- * }
- *
- * return NULL;
- * }
- * ]|
- *
- * Returns: (transfer none): the topmost ancestor of @widget, or @widget itself
- * if there’s no ancestor.
- **/
-GtkWidget *
-gtk_widget_get_toplevel (GtkWidget *widget)
-{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
-
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
- while (priv->parent)
- {
- widget = priv->parent;
- priv = gtk_widget_get_instance_private (widget);
- }
-
- return widget;
-}
-
/**
* gtk_widget_get_ancestor:
* @widget: a #GtkWidget
* Gets the first ancestor of @widget with type @widget_type. For example,
* `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets
* the first #GtkBox that’s an ancestor of @widget. No reference will be
- * added to the returned widget; it should not be unreferenced. See note
- * about checking for a toplevel #GtkWindow in the docs for
- * gtk_widget_get_toplevel().
+ * added to the returned widget; it should not be unreferenced.
*
* Note that unlike gtk_widget_is_ancestor(), gtk_widget_get_ancestor()
* considers @widget to be an ancestor of itself.